import http from '@ohos.net.http';
//轻量级存储
import storage from '@system.storage';

export function changePreState(ID,State,callback){
    var token;
    storage.get({
        key:"token",
        success(data){
            console.log("CHWxxx---获取成功 = " + data)
            token = data;
            let httpRequest = http.createHttp();
            httpRequest.request(
                "https://www.xdsbty.cn/user/editprescription",
                {
                    method:'POST',
                    header: {
                        'Content-Type': 'application/json',
                        'Token':token
                    },
                    extraData: {
                        id: ID,
                        state: State
                    },
                    readTimeout: 10000,
                    connectTimeout: 10000
                }, (err, data) => {
                if (!err) {
                    console.info("utils xxx--- "+data.result )
                    callback(data.result)
                } else {
                    console.info('utils xxx--- error:' + JSON.stringify(err));
                    callback("error")
                }
            })
        },
        fail(data,code){
            console.log("CHWxxx---" + data)
        },
        complete(){
        }
    })



}